There are various types of recording media for recording digital data such as music contents and image data, the media, for example, a magnetic disk, an optical disk, and a magnetooptical disk. A memory card that is a type of the recording media mainly employs a semiconductor memory, for example, a flash ROM as a recording element, and rapidly spreads mainly in a small-size portable apparatus, for example, a digital still camera and a mobile phone terminal because the recording medium can be downsized.
In such memory card, a semiconductor element called a NAND type flash memory is mainly used as the recording element. The NAND type flash memory is a recording memory able to store, after preliminarily erasing already-stored data, other data again, and can constitute a memory card able to be rewritten more than once in a manner similar to a conventional hard disk.
Meanwhile, as a recording element different from the NAND type flash memory, an OTP (One Time Programmable) memory that can be manufactured in a low cost by applying a conventional technique of the COMS process has recently appeared and attracts attention. The OTP memory is a write once memory that restricts an identical physical memory region to be recorded only once. This memory may spread especially as a recording element of a memory card used for long-term storage of data as well as media such as the DVD-R because of a low manufacturing cost. Specifically, these recording elements can be used in accordance with user needs by preparing: a relatively high-priced memory card for sale employing the NAND type flash memory for a purpose requiring the rewriting many times as in the conventional memory card; and a relatively low-priced memory card for sale employing the OTP memory for a purpose not requiring the rewriting after recording data once.
In addition, data stored in the memory card is conventionally managed by a file system, and a user can easily handle the stored data as a file. For example, a FAT file system, a UDF file system (Universal Disk Format), and a NTFS file system (New Technology File System) exist as the conventionally used file system. Since being able to share a file with an apparatus able to interpret the same file system, the memory card that manages data by using the file system is able to receive and send data from and to the apparatus.
Here, the FAT file system will be described as one example of the conventional file system. FIG. 1 shows a logical address space, and a region retaining file system management information 100 exists at a starting position of the logical address space. The file system management information 100 is a region for storing management information of the file system, for example, an allocation unit of region and a size of the region managed by the file system. Management information of the file system called a master boot record and partition table 102, a partition boot sector 103, FATs (104 and 105), and a root directory entry 106 are included in the file system management information, and each include information required to manage a region of user data 101. The master boot record and partition table 102 is a region for storing information used for managing a region on the logical address space managed by the file system by dividing the region into a plurality of regions called a partition. The partition boot sector 103 is a region for storing management information for one partition. The FATS (104 and 105) are regions for storing information related to a storage position of data included in a file; the two FATs (104 and 105) having the same information generally exist in the memory card and are duplicated so that an file access can be ensured by using one of the FATs (104 and 105) even when the other one corrupts. The root directory entry 106 is a portion for storing: a file existing immediately below a root directory; and information of directory (directory entry).
In the FAT file system, a region for storing the user data 101 such as data of a file body exists following the region for retaining the file system management information 100. The user data 101 is divided and managed in management units called a cluster having a size of 16 kB or 32 kB, and each cluster stores data included in a file. A file storing lots of data stores the data striding over a plurality of clusters, links between the clusters are managed by link information stored in the FATs (104 and 105). In addition, a file existing in a directory immediately below a root directory and information of subdirectory (the directory entry) are stored by using a part of the user data 101.
Next, referring to FIG. 2 to FIG. 5, an example of writing of file data in the FAT file system will be explained. FIG. 2 is a view showing a configuration of the directory entry. FIG. 3 is a view showing a procedure of file data writing process. FIG. 4 is a view showing one example of a directory entry 107, the FATs (104 and 105), and the user data 101 before the writing. FIG. 5 is a view showing one example of the directory entry 107, the FATs (104 and 105), and the user data 101 after the writing.
As described above, in the FAT file system, the directory entry 107 storing information, for example, a file name, file size, and file attribution shown in FIG. 5(a) is stored in the root directory entry 106 and a part of the user data 101. As shown in FIG. 2, the directory entry 107 in the FAT file system is composed of 32 bytes and stores a file name, attributes, last update date and time, a starting cluster number, a file size, and so on.
Next, referring to FIG. 3, the procedure of the file data writing process will be explained.
(S101) The directory entry 107 of an object file is read.
(S102) The starting cluster number stored in the read directory entry 107 is obtained and a starting position of file data is confirmed.
(S103) A cluster number of a writing position is obtained by reading FATs (104 and 105) and following the links in turn from the starting position of file data obtained at S102 on the FATs (104 and 105).
(S104) It is judged whether or not it is required to allocate new empty region to the file in the data writing. The processing proceeds to S105 when the allocation of empty region is required. The processing proceeds to S106 when the allocation of empty region is not required.
(S105) The empty region on the FATs (104 and 105) is searched and the empty region of one cluster is allocated to a termination.
(S106) Data of the maximal size that can be written to the presently referred cluster to the user data 101 is written.
(S107) It is judged whether or not the writing of all data has been completed. The processing returns to S104 when data still remains. The processing proceeds to S108 when the writing of all data has been completed.
(S108) The file size, the last update date and time, and so on stored in the directory entry 107 are updated, and the directory entry 107 is overwritten.
(S109) The FATs (104 and 105) is overwritten and the processing is completed.
According to the processing of the file data writing, when data of 10000 bytes is further written to FILE1.TXT having data of 60000 bytes shown in FIG. 4, it changes to a file having data of 70000 bytes as shown in FIG. 5.
When storing file data, the FAT file system accordingly requires storing the directory entry 107, the FATs (104 and 105), and so on with the main data in a card. Since this information has to be overwritten for the same logical address in every updating, there is a problem that does not allow applying the above-mentioned FAT file system to the OTP memory that can record data only once.
As a conventional method for solving such problem, Patent document 1 proposes a method for realizing the overwriting in a pseudo manner by using a function to converting a logical address into a physical address in a storage medium using the OTP memory. This conventional method applies a function of conversion between a logical address and a physical address to realize the pseudo overwriting by newly allocating a part of a region ensured as a substitute region for a defective block at occurrence of the data overwriting and changing a data recording position on the basis of the address conversion.
Next, referring to FIG. 6, a conventional procedure of file data writing process applied to an information recording device that can rewrite data more than once will be explained.
(S201) An access device calculates a remaining capacity on the basis of the FATs (104 and 105) read from the information recording device into a RAM on the access device. Since a value of the FAT entry corresponding to an empty cluster is set to “0”, the remaining capacity can be calculated by retrieving all FAT entries and counting the number of entries whose values are set to “0”. In addition, reading of the FATS (104 and 105) is preliminarily completed, for example, immediately after attachment of the information recording device to the access device.
(S202) The access device judges based on the calculated remaining capacity whether or not file data can be stored. This judgment can be realized by comparing a size of the remaining capacity with a size of data written in a single file data recording. For example, when the file data writing is performed in units of clusters, the recording is judged to be possible in a case where the remaining capacity obtained at S201 has one cluster or more and is judged to be impossible in other case.
(S203) In the case where the recording is judged to be possible at S202, the access device searches an empty region with a data size written in a single file data recording on the FAT and allocates a recording region on the FAT by setting a FAT entry of the region to a value other than “0” on the RAM.
(S204) and (S205) The access device sends a command for writing the file data to the recording region allocated at S203. The information recording device receives the write command issued from the access device at S204.
(S206) The information recording device searches a recordable region on recording elements such as the NAND type flash memory and records the file data.
(S207) The information recording device updates address management information so that a physical address of the region where the file data was recorded at S206 can correspond to a logical address designated in the writing command by the access device at S204.
(S208) and (S209) As a response to the write command, the information recording device returns a recording completion response indicating completion of the recording to the access device, and the access device receives this response.
Then, while there is file data to be recorded, processes from S201 to S209 are repeated.
As described above, in the conventional procedure of the file data writing process, the remaining capacity is managed on the FAT, and the access device knows the remaining capacity by counting the number of empty clusters on the FAT.    Patent document 1: Japanese Unexamined Patent Publication No. 2006-85859